<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:cc="http://java.sun.com/jsf/composite"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <!-- INTERFACE -->
    <cc:interface>
        <cc:attribute name="var" type="java.lang.Object" required="true" />
        <cc:attribute name="bean" type="java.lang.Object" required="true"  />    
        <cc:attribute name="pubMethod" type="java.lang.String" required="true" />
        <cc:attribute name="propertyPub" type="java.lang.String" required="true" />
        <cc:attribute name="propertyUser" type="java.lang.String" required="true" />
        <cc:attribute name="propertyAlq" type="java.lang.String" required="true" />
        <cc:attribute name="userMethod" type="java.lang.String" required="true"/>
        <cc:attribute name="metodoAceptar" type="java.lang.String" required="true"/>
        <cc:attribute name="metodoRechazar" type="java.lang.String" required="true"/>
        <cc:attribute name="metodoCancelarPedido" type="java.lang.String" />
        <cc:attribute name="lista" type="java.lang.String" required="true"/>
        <cc:attribute name="confirmable" type="java.lang.Boolean" default="false" />
        <cc:attribute name="cancelable" type="java.lang.Boolean" default="false" />
    </cc:interface>

    <!-- IMPLEMENTATION -->
    <cc:implementation>
        <div class="itemAlquiler">

            <h:panelGrid columns="4"> 
                <h:panelGrid columns="1">
                    <h:graphicImage value="/image?id=#{cc.attrs.var.imagenId}" 
                                    width="113" height="85" style="border: 1px solid gray; margin-top: 5px"
                                    rendered="#{cc.attrs.var.imagenId != -1}" />
                    <h:graphicImage value="#{resource['images:noImage.png']}"
                                    width="113" height="85" style="border: 1px solid gray; margin-top: 5px"
                                    rendered="#{cc.attrs.var.imagenId == -1}" />
                </h:panelGrid>

                <h:panelGrid columns="1" >
                    <h:link value="#{cc.attrs.var.titulo}" outcome="/vistas/mostrarPublicacion" >
                        <f:param name="id" value="#{cc.attrs.var.idPublicacion}" />                        
                    </h:link>
                    <h:link value="#{cc.attrs.var.usuario}" outcome="/vistas/verReputacion" >
                        <f:param name="id" value="#{cc.attrs.var.idUsuario}" />
                    </h:link>

                </h:panelGrid>

                <h:panelGrid columns="1" >
                    <h:outputText value="cantidad: #{cc.attrs.var.cantidad}, $ #{cc.attrs.var.monto}" />
                    <h:outputLabel value="Comienza: #{cc.attrs.var.fechaDesde}" />
                    <h:outputLabel value="Finaliza: #{cc.attrs.var.fechaHasta}" />
                </h:panelGrid>

                <h:panelGrid columns="1">
                    <p:commandButton value="Cancelar Pedido" 
                                     actionListener="#{cc.attrs.bean[cc.attrs.metodoCancelarPedido]}"
                                     update="#{cc.attrs.lista}" rendered="#{cc.attrs.cancelable}">
                        <f:attribute name="alq" value="#{cc.attrs.var.idAlquiler}" />
                    </p:commandButton>
                    <p:commandButton value="Aceptar" actionListener="#{cc.attrs.bean[cc.attrs.metodoAceptar]}"
                                     update="#{cc.attrs.lista}" rendered="#{cc.attrs.confirmable}">
                        <f:attribute name="alq" value="#{cc.attrs.var.idAlquiler}" />
                    </p:commandButton>
                    <p:commandButton value="Rechazar" actionListener="#{cc.attrs.bean[cc.attrs.metodoRechazar]}"
                                     update="#{cc.attrs.lista}" rendered="#{cc.attrs.confirmable}"> 
                        <f:attribute name="alq" value="#{cc.attrs.var.idAlquiler}" />
                    </p:commandButton>
                </h:panelGrid>


            </h:panelGrid>


        </div>
    </cc:implementation>
</html>
